package com.foreknow.elm.controller;

import com.foreknow.elm.po.User;
import com.foreknow.elm.service.UserService;
import com.foreknow.elm.service.impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 啊滨
 * @date 2023/2/14 10:15
 */
public class UserController {
    public Object getUserByIdByPass(HttpServletRequest request){
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        UserService service=new UserServiceImpl();
        return service.getUserByIdByPass(userId,password);
    }

    public Object getUserById(HttpServletRequest request){
        int count=0;
        String userId = request.getParameter("userId");
        UserService service=new UserServiceImpl();
        count = service.getUserById(userId);
        return count;
    }

    public Object saveUser(HttpServletRequest request){
        int isRight=0;
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        String userName = request.getParameter("userName");
        int userSex = Integer.parseInt(request.getParameter("userSex"));
        UserService service=new UserServiceImpl();
        isRight = service.saveUser(userId,password,userName,userSex);
        return  isRight;
    }
}
